<?php
namespace app\api\controller;

use app\api\model\Configs;
use app\api\model\Goods;

class Index extends Base
{
    // 是否自动实例化当前模型
    protected $autoNewModel = false;
    // 是否开启自动验证
    protected $autoValidateCheck = false;

    public function information()
    {
        $lasted_version = Configs::where('alias', 'APP_LASTED_VERSION')->value('content');
        $enabled_version = Configs::where('alias', 'APP_ENABLED_VERSIONS')->value('content');
        $app_upgrade_link = Configs::where('alias', 'APP_UPGRADE_LINK_FPR_ANDROID')->value('content');
        //整理数据
        $data = [
            'title'=>'众益健康',
            'unread_message'=>'true',
            'search'=>[
                'enable'=>false,
                'placeholder'=>'',
                'scan'=>true,
                'alias'=>'none',
                'params'=>[]
            ],
            'banners'=>[
                'enable'=>true,
                'lists'=>[
                    [
                        'name'=>'',
                        'img'=>get_oss_url('/static/system/index/banner1.png'),
                        'alias'=>'',
                        'params'=>[],
                    ],
                ]
            ],
            'ensures'=>[
                'enable'=>true,
                'lists'=>[
                    [
                        'img'=>get_oss_url('/static/system/index/ensures-1.png'),
                        'text'=>'品质保障'
                    ],
                    [
                        'img'=>get_oss_url('/static/system/index/ensures-2.png'),
                        'text'=>'正品授权'
                    ],
                    [
                        'img'=>get_oss_url('/static/system/index/ensures-3.png'),
                        'text'=>'臻选优品'
                    ],
                    [
                        'img'=>get_oss_url('/static/system/index/ensures-4.png'),
                        'text'=>'退换无忧'
                    ]
                ]
            ],
            'navigations'=>[
                'enable'=>true,
                'lists'=>[
                    [
                        'id'=>0,
                        'name'=>'抗衰美颜',
                        'logo'=>get_oss_url('/static/system/index/navigations1.png'),
                        'alias'=>'',
                        'params'=>[],
                    ],
                    [
                        'id'=>0,
                        'name'=>'保健养生',
                        'logo'=>get_oss_url('/static/system/index/navigations2.png'),
                        'alias'=>'',
                        'params'=>[],
                    ],
                    [
                        'id'=>0,
                        'name'=>'理疗设备',
                        'logo'=>get_oss_url('/static/system/index/navigations3.png'),
                        'alias'=>'',
                        'params'=>[],
                    ],
                    [
                        'id'=>0,
                        'name'=>'四高养护',
                        'logo'=>get_oss_url('/static/system/index/navigations4.png'),
                        'alias'=>'',
                        'params'=>[],
                    ],
                    [
                        'id'=>0,
                        'name'=>'经络养护',
                        'logo'=>get_oss_url('/static/system/index/navigations5.png'),
                        'alias'=>'',
                        'params'=>[],
                    ],
                ]
            ],
            'notices'=>[
                'enable'=>true,
                'text'=>'商城V1.0.0版本正式发布，欢迎新老用户体验与反馈！',
                'alias'=>'',
                'params'=>[]
            ],
            'thematic'=>[
                'enable'=>false,
                'left'=>[
                    'title'=>'测试',
                    'img'=>get_oss_url('/static/system/index/bpzq.png'),
                    'alias'=>'',
                    'params'=>[],
                    'lists'=>Goods::getIndexThematic(4)
//                        [
//                        [
//                            'code'=>'',
//                            'cover'=>get_oss_url('/static/system/index/zone-1.png'),
//                            'title'=>'',
//                            'amount'=>0,
//                            'market_amount'=>0,
//                            'alias'=>'',
//                            'params'=>[],
//                        ],
//                        [
//                            'code'=>'',
//                            'cover'=>get_oss_url('/static/system/index/zone-1.png'),
//                            'title'=>'',
//                            'amount'=>0,
//                            'market_amount'=>0,
//                            'alias'=>'',
//                            'params'=>[],
//                        ],
//                        [
//                            'code'=>'',
//                            'cover'=>get_oss_url('/static/system/index/zone-1.png'),
//                            'title'=>'',
//                            'amount'=>0,
//                            'market_amount'=>0,
//                            'alias'=>'',
//                            'params'=>[],
//                        ],
//                        [
//                            'code'=>'',
//                            'cover'=>get_oss_url('/static/system/index/zone-1.png'),
//                            'title'=>'',
//                            'amount'=>0,
//                            'market_amount'=>0,
//                            'alias'=>'',
//                            'params'=>[],
//                        ],
//                    ]
                ],
                'right'=>[
                    [
                        'title'=>'便宜好货',
                        'desc'=>'便宜实用 必备品',
                        'img'=>get_new_url(Goods::where('id', 1)->value('cover')),//get_oss_url('/static/system/index/zone-1.png'),
                        'alias'=>'goods.detail',
                        'params'=>[
                            'id'=>1
                        ],
                    ],
                    [
                        'title'=>'TOP榜单',
                        'desc'=>'实时更新',
                        'img'=>get_new_url(Goods::where('id', 2)->value('cover')),//get_oss_url('/static/system/index/zone-2.png'),
                        'alias'=>'goods.detail',
                        'params'=>[
                            'id'=>2
                        ],
                    ],
                ],
            ],
            'activity'=>[
                'enable'=>true,
                'name'=>'',
                'img'=>get_oss_url('/static/system/index/activity1.png'),
                'alias'=>'',
                'params'=>[
                    'type'=>''
                ],
            ],
            'brand'=>[
                'enable'=>false,
                'title'=>'',
                'more'=>'',
                'alias'=>'none',
                'params'=>[],
                'lists'=>[
                    [
                        'code'=>'',
                        'cover'=>'',
                        'title'=>'',
                        'amount'=>0,
                        'market_amount'=>0,
                        'alias'=>'none',
                        'params'=>[],
                    ],
                ]
            ],
//            'recommend'=>[
//                'enable'=>true,
//                'title'=>'新品上市',
//                'more'=>'查看更多',
//                'alias'=>'',
//                'params'=>[],
//                'lists'=>Goods::getNewArrival()
////                'lists'=>[
////                    [
////                        'code'=>'',
////                        'cover'=>'',
////                        'title'=>'',
////                        'amount'=>0,
////                        'market_amount'=>0,
////                        'alias'=>'none',
////                        'params'=>[],
////                    ],
////                ]
//            ],
            'new_arrival'=>[
                'enable'=>true,
                'title'=>'新品上市',
                'more'=>'查看更多',
                'alias'=>'',
                'params'=>[],
                'lists'=>Goods::getNewArrival()
            ],
            'lists'=>[
                'enable'=>false,
                'title'=>'',
                'filters'=>[]
            ],


//            'banner_list'=>[
//                'enable' => true,
//                'title' => '轮播图',
//                'contents' => [
//                    ['alias' => 'merchant.info', 'params' => ['merchant_id'=>3], 'name' => '云尚优品 云尚整装','path_name' => '今日爆款', 'image' => \app\model\Base::getOssUrl() . '/static/app/banner/11.png'],
//                    ['alias' => 'merchant.info', 'params' => ['merchant_id'=>1], 'name' => '云尚优品 云尚优品生鲜店','path_name' => '今日爆款', 'image' => \app\model\Base::getOssUrl() . '/static/app/banner/12.png'],
//                    ['alias' => 'merchant.info', 'params' => ['merchant_id'=>1], 'name' => '云尚优品 云尚优品生态猪','path_name' => '今日爆款', 'image' => \app\model\Base::getOssUrl() . '/static/app/banner/13.png'],
//                    ['alias' => 'merchant.info', 'params' => ['merchant_id'=>2], 'name' => '云尚优品 云尚优品生态农业','path_name' => '今日爆款', 'image' => \app\model\Base::getOssUrl() . '/static/app/banner/14.png'],
//                    ['alias' => 'merchant.info', 'params' => ['merchant_id'=>2], 'name' => '云尚优品 乡村振兴战略','path_name' => '今日爆款', 'image' => \app\model\Base::getOssUrl() . '/static/app/banner/15.png'],
//                ]
//            ],
//            'top_menu' => [
//                'enable' => true,
//                'title' => '顶部菜单',
//                'contents' => [
//                    ['alias' => 'goods.detail', 'params' => ['id'=>87], 'name' => '今日爆款', 'logo' => 'medias/merchants/reward.png', 'icon'=>'icon-baokuan'],
//                    ['alias' => 'goods.detail', 'params' => ['id'=>104], 'name' => '生态产品', 'logo' => 'medias/merchants/reward.png', 'icon'=>'icon-rou'],
//                    ['alias' => 'goods.detail', 'params' => ['id'=>105], 'name' => '兑换商城', 'logo' => 'medias/merchants/reward.png', 'icon'=>'icon-jifenshangcheng1'],
//                    ['alias' => 'goods.detail', 'params' => ['id'=>106], 'name' => '万款产品', 'logo' => 'medias/merchants/reward.png', 'icon'=>'icon-leimucuquanbu'],
//                ]
//            ],
//            'second_banner' => [
//                'enable' => true,
//                'title' => '二级轮播图',
//                'contents' => [
//                    ['alias' => 'goods.detail', 'params' => ['id'=>99], 'name' => '今日爆款', 'logo' => \app\model\Base::getNewUrl() . '/static/app/second_banner/1.png'],
//                    ['alias' => 'goods.detail', 'params' => ['id'=>100], 'name' => '今日爆款', 'logo' => \app\model\Base::getNewUrl() . '/static/app/second_banner/2.png'],
//                    ['alias' => 'goods.detail', 'params' => ['id'=>101], 'name' => '今日爆款', 'logo' => \app\model\Base::getNewUrl() . '/static/app/second_banner/3.png'],
//                    ['alias' => 'goods.detail', 'params' => ['id'=>102], 'name' => '今日爆款', 'logo' => \app\model\Base::getNewUrl() . '/static/app/second_banner/4.png'],
//                ]
//            ],
//            'category' => [
//                'enable' => true,
//                'title' => '分类',
//                'contents' => [
//                    ['alias' => 'category.category', 'params' => ['cate_id'=>1], 'name' => '生态肉类', 'sub_name' => 'PORK', 'logo' => \app\model\Base::getNewUrl() . '/static/app/category/1.png', 'class' => 'border-right-003 border-bottom-003'],
//                    ['alias' => 'category.category', 'params' => ['cate_id'=>2], 'name' => '大健康类', 'sub_name' => 'HEALTH', 'logo' => \app\model\Base::getNewUrl() . '/static/app/category/5.png', 'class' => 'border-right-003 '],
//                    ['alias' => 'category.category', 'params' => ['cate_id'=>3], 'name' => '云尚整装', 'sub_name' => 'DECORAIONS', 'logo' => \app\model\Base::getNewUrl() . '/static/app/category/3.png', 'class' => 'border-right-003 border-bottom-003'],
//                    ['alias' => 'category.category', 'params' => ['cate_id'=>4], 'name' => '生鲜果蔬', 'sub_name' => 'GENERAL', 'logo' => \app\model\Base::getNewUrl() . '/static/app/category/2.png', 'class' => 'border-bottom-003'],
//                    ['alias' => 'category.category', 'params' => ['cate_id'=>5], 'name' => '牧草品类', 'sub_name' => 'MAKEUP', 'logo' => \app\model\Base::getNewUrl() . '/static/app/category/4.png', 'class' => 'border-bottom-003'],
//                    ['alias' => 'category.category', 'params' => ['cate_id'=>1], 'name' => '全部品类', 'sub_name' => 'MORE', 'logo' => \app\model\Base::getNewUrl() . '/static/app/category/6.png', 'class' => ''],
//                ]
//            ],
//            'middle_banner' => [
//                'enable' => true,
//                'title' => '中间广告图',
//                'logo' => \app\model\Base::getNewUrl() . '/static/app/middle_banner/1.png',
//                'alias' => 'merchant.cashier',
//                'params' => ['merchant_id'=>1]
//            ],
//            'middle_banner' => [
//                'enable' => false,
//                'title' => '中间广告图',
//                'logo' => \app\model\Base::getNewUrl() . '/static/app/middle_banner/3.png',
////                'alias' => 'goods.detail',
////                'params' => ['id'=>107],
//                'alias' => 'goods.pig',
//                'params' => []
//            ],
//            'product_list'=>(new \app\api\model\Product())->getIndexRecProduct()
//
//            'tools' => [
//                'enable' => true,
//                'title' => '商家工具',
//                'contents' => [
//                    ['alias' => 'wallet.transfer', 'params' => [], 'name' => '余额转账', 'logo' => 'medias/merchants/reward.png'],
//                    ['alias' => 'wallet.exchange', 'params' => [], 'name' => '余额兑换', 'logo' => 'medias/merchants/reward.png'],
//                    ['alias' => 'coins.statistics', 'params' => [], 'name' => '余额充值', 'logo' => 'medias/merchants/reward.png'],
//                    ['alias' => 'account.service', 'params' => [], 'name' => '扫一扫', 'logo' => 'medias/merchants/reward.png'],
//                ]
//            ],
//            'service' => [
//                'enable' => true,
//                'title' => '更多服务',
//                'contents' => [
//                    ['alias' => 'wallet.transfer', 'params' => [], 'name' => '实名认证', 'logo' => 'medias/merchants/reward.png'],
//                    ['alias' => 'wallet.exchange', 'params' => [], 'name' => '银行卡管理', 'logo' => 'medias/merchants/reward.png'],
//                    ['alias' => 'coins.statistics', 'params' => [], 'name' => '认养计划', 'logo' => 'medias/merchants/reward.png'],
//                    ['alias' => 'account.service', 'params' => [], 'name' => '财富规划', 'logo' => 'medias/merchants/reward.png'],
//                    ['alias' => 'wallet.transfer', 'params' => [], 'name' => '相关设置', 'logo' => 'medias/merchants/reward.png'],
//                    ['alias' => 'wallet.exchange', 'params' => [], 'name' => '我的客服', 'logo' => 'medias/merchants/reward.png'],
//                    ['alias' => 'coins.statistics', 'params' => [], 'name' => '推广分享', 'logo' => 'medias/merchants/reward.png'],
//                    ['alias' => 'account.service', 'params' => [], 'name' => '我的关注', 'logo' => 'medias/merchants/reward.png'],
//                ]
//            ],

//            'upgrade' => ['version' => 'V1.0.1', 'version_num' => 200, 'link' => 'https://www.baidu.com']
            'upgrade' => ['version' => $lasted_version, 'version_num' => $enabled_version, 'link' => $app_upgrade_link]
        ];

        return showSuccess($data);
    }

    public function oauthInformation(){
        //整理数据
        $data = [
            'logo'=> get_oss_url('/static/logo.png'),
            'main_title'=> '登录',
            'title'=> '欢迎来到 云尚优品',
            'description'=>'请使用手机号码进行登录',
            'wechat'=>[
                'enable'=> false, 'title'=> '', 'alias'=> '', 'show'=> false, 'tip'=> ''
            ],
            'third_platform'=> [
                'enable'=> false,
                'providers'=> [
                    [
                        'alias'=> 'sinaweibo',
                        'logo'=> ''
                    ],
                    [
                        'alias'=> 'weixin',
                        'logo'=> ''
                    ],
                    [
                        'alias'=> 'qq',
                        'logo'=> ''
                    ]
                ]
            ],
        ];
        return showSuccess($data);
    }
}